package Forms;

import Classes.*;
import static Forms._UAdmin.mi;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
/**
 *
 * @author Owner
 */
public class CurrDetails1 extends javax.swing.JFrame {

    static MInterface mi;
    static User cUser;
    static String sss;
    static Curriculum curr;
    static ArrayList<SchoolYear> syList;
    static ArrayList<Curriculum> currList;
    DefaultTableModel currdtm;
    static ArrayList<ClassLevel> clevelList;
    ArrayList<Curriculum> selected = new ArrayList<Curriculum>();
    DefaultTableModel cleveldtm1;
    DefaultTableModel cleveldtm2;
    ArrayList<ClassLevel> cl1;
    ArrayList<ClassLevel> cl2 = new ArrayList<ClassLevel>();
    static ArrayList<ClassLevel> clevelsyList;
    static ArrayList<Subject> subjList;
    DefaultTableModel subjdtm1;
    DefaultTableModel subjdtm2;
    ArrayList<Subject> subj1;
    ArrayList<Subject> subj2 = new ArrayList<Subject>();
    static ArrayList<Sections> secList;
    DefaultTableModel secdtm1;
    DefaultTableModel secdtm2;
    ArrayList<Sections> sec1;
    ArrayList<Sections> sec2 = new ArrayList<Sections>();
    String currentSY = null;
    SchoolYear sy;
    String syID;

    /**
     * Creates new form Admin
     */
    public CurrDetails1(User user, MInterface i, String a, Curriculum b) {

        initComponents();
        this.setLocationRelativeTo(getRootPane());
        cUser = user;
        mi = i;
        sss = a;
        curr = b;
        try {
            timeL.setText(mi.getCurrentTime());
            dateL.setText(mi.getCurrentDate());
            usernameL.setText(cUser.getName());

//            if (a.equals("open")) {
//                p2.setEnabled(false);
//                p3.setEnabled(false);
//                p4.setEnabled(false);
//                loadCurrSY("add");
//                currdtm = new DefaultTableModel(new String[]{currTbl.getColumnName(0)}, 0);
//
//                currList = (ArrayList<Curriculum>) mi.getList2("getlist2-curriculumopensy", syCB.getSelectedItem().toString().split("-")[0], "").clone();
//                loadCurrCB();
//
//            } else {
//                loadCurrSY("view");
//
//                sy = (SchoolYear) mi.get("get-sy", b.getCurrSY(), "");
//                syCB.setSelectedItem(b.getCurrSY());
//                syCB.setEnabled(false);
//                startC.setEnabled(false);
//                ((JTextField) startC.getDateEditor().getUiComponent()).setText(sy.getSyStart());
//                endC.setEnabled(false);
//                ((JTextField) endC.getDateEditor().getUiComponent()).setText(sy.getSyEnd());
//                numdays.setEnabled(false);
//                numdays.setText(sy.getNumOfDays() + "");
//                compute.setEnabled(false);
//
//
//                currList = (ArrayList<Curriculum>) mi.getList2("getlist2-currdetailscurriculum", b.getSyID(), "").clone();
//                currdtm = new DefaultTableModel(new String[]{currTbl.getColumnName(0)}, 0);
//                currTbl.setModel(currdtm);
//                for (int x = 0; x < currList.size(); x++) {
//                    currdtm.addRow(new Object[]{currList.get(x).getCurrName()});
//
//                }
//                
//                load1b();
//                load2b();
//                load3b();
//
//                add1.setEnabled(false);
//
//            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void compute() {
//        int schoolDays = 0;
//        Calendar st = Calendar.getInstance();
//        Calendar en = Calendar.getInstance();
//
//        Date s = startC.getDate();
//        Date e = endC.getDate();
//
//        st.setTime(s);
//        en.setTime(e);
//
//        do {
//            st.add(Calendar.DAY_OF_MONTH, 1);
//            if (st.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && st.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY && en.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && en.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
//                schoolDays++;
//            }
//        } while (st.getTimeInMillis() < en.getTimeInMillis());
//        numdays.setText(String.valueOf(schoolDays));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        dateL = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        timeL = new javax.swing.JLabel();
        usernameL = new javax.swing.JLabel();
        logoutB = new javax.swing.JButton();
        mainP = new javax.swing.JTabbedPane();
        p1 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        save1 = new javax.swing.JButton();
        cancel1 = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        p2 = new javax.swing.JPanel();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        clevel1 = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        jLabel2 = new javax.swing.JLabel();
        label2a = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        currCB2 = new javax.swing.JComboBox();
        add2 = new javax.swing.JButton();
        remove2 = new javax.swing.JButton();
        addclevel = new javax.swing.JButton();
        save2 = new javax.swing.JButton();
        cancel2 = new javax.swing.JButton();
        jPanel13 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        clevel2 = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        jLabel13 = new javax.swing.JLabel();
        label2b = new javax.swing.JLabel();
        p3 = new javax.swing.JPanel();
        jPanel14 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        sub1 = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        jLabel25 = new javax.swing.JLabel();
        label4a = new javax.swing.JLabel();
        clevelCB3 = new javax.swing.JComboBox();
        jLabel40 = new javax.swing.JLabel();
        add3 = new javax.swing.JButton();
        remove3 = new javax.swing.JButton();
        addsubj = new javax.swing.JButton();
        save3 = new javax.swing.JButton();
        cancel3 = new javax.swing.JButton();
        jPanel15 = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        sub2 = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        jLabel28 = new javax.swing.JLabel();
        label4b = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();

        setTitle("Curriculum Details");

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resources/banner.jpg"))); // NOI18N
        jLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        dateL.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        dateL.setText("mm/dd/yy");

        jSeparator1.setForeground(new java.awt.Color(0, 102, 51));

        timeL.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        timeL.setText("hh:mm am/pm");

        usernameL.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        usernameL.setText("username");

        logoutB.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        logoutB.setText("Logout");
        logoutB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutBActionPerformed(evt);
            }
        });

        mainP.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        mainP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mainPMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mainPMouseEntered(evt);
            }
        });

        jPanel11.setBackground(new java.awt.Color(255, 255, 255));
        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", 0, 0, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        save1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        save1.setText("Save");
        save1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                save1ActionPerformed(evt);
            }
        });

        cancel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        cancel1.setText("Cancel");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel10.setText("Date Effective:");

        jComboBox2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabel23.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel23.setText("Date Encoded:");

        jLabel24.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel24.setText("mm/dd/yyyy");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel8.setText("Curriculum Name:");

        jTextField2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel9.setText("Curriculum Description:");

        jTextArea1.setColumns(20);
        jTextArea1.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N
        jTextArea1.setRows(5);
        jScrollPane4.setViewportView(jTextArea1);

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel11Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel23)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel24)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(save1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancel1))
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane4)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel11Layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel11Layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)))))
                .addContainerGap())
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(jLabel24))
                .addGap(18, 18, 18)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancel1)
                    .addComponent(save1))
                .addContainerGap())
        );

        javax.swing.GroupLayout p1Layout = new javax.swing.GroupLayout(p1);
        p1.setLayout(p1Layout);
        p1Layout.setHorizontalGroup(
            p1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(p1Layout.createSequentialGroup()
                .addGap(243, 243, 243)
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(277, Short.MAX_VALUE))
        );
        p1Layout.setVerticalGroup(
            p1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(p1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(93, Short.MAX_VALUE))
        );

        mainP.addTab("Curriculum", p1);

        jPanel12.setBackground(new java.awt.Color(255, 255, 255));
        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "List of Available Class Levels", 0, 0, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        clevel1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Class Level", "Category"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(clevel1);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel2.setText("No. of Entries:");

        label2a.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        label2a.setText("000");

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel12.setText("Level Category:");

        currCB2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                currCB2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 425, Short.MAX_VALUE)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label2a)
                        .addGap(0, 293, Short.MAX_VALUE))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(currCB2, 0, 313, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(currCB2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(label2a)))
        );

        add2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        add2.setText("Add >>");
        add2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                add2ActionPerformed(evt);
            }
        });

        remove2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        remove2.setText("<< Remove");
        remove2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                remove2ActionPerformed(evt);
            }
        });

        addclevel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        addclevel.setText("Add Class Level");
        addclevel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addclevelActionPerformed(evt);
            }
        });

        save2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        save2.setText("Save");
        save2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                save2ActionPerformed(evt);
            }
        });

        cancel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        cancel2.setText("Cancel");
        cancel2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancel2ActionPerformed(evt);
            }
        });

        jPanel13.setBackground(new java.awt.Color(255, 255, 255));
        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Chosen Class Levels", 0, 0, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        clevel2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Class Level", "Category"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        clevel2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                clevel2MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(clevel2);

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel13.setText("No. of Entries:");

        label2b.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        label2b.setText("000");

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label2b))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 353, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(label2b)))
        );

        javax.swing.GroupLayout p2Layout = new javax.swing.GroupLayout(p2);
        p2.setLayout(p2Layout);
        p2Layout.setHorizontalGroup(
            p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(p2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p2Layout.createSequentialGroup()
                        .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(remove2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(add2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, 383, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(p2Layout.createSequentialGroup()
                        .addComponent(addclevel, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 670, Short.MAX_VALUE)
                        .addComponent(save2, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancel2)))
                .addContainerGap(65, Short.MAX_VALUE))
        );
        p2Layout.setVerticalGroup(
            p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(p2Layout.createSequentialGroup()
                .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p2Layout.createSequentialGroup()
                        .addGap(177, 177, 177)
                        .addComponent(add2, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(remove2, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(p2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(save2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(cancel2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(addclevel, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        mainP.addTab("Class Level", p2);

        jPanel14.setBackground(new java.awt.Color(255, 255, 255));
        jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "List of Available Subjects", 0, 0, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        sub1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Subject", "Description", "Units"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane5.setViewportView(sub1);

        jLabel25.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel25.setText("No. of Entries:");

        label4a.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        label4a.setText("000");

        clevelCB3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clevelCB3ActionPerformed(evt);
            }
        });

        jLabel40.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel40.setText("Class Level:");

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(jLabel25)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label4a)
                        .addGap(0, 245, Short.MAX_VALUE))
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(jLabel40)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(clevelCB3, 0, 294, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel40)
                    .addComponent(clevelCB3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel25)
                    .addComponent(label4a)))
        );

        add3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        add3.setText("Add >>");
        add3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                add3ActionPerformed(evt);
            }
        });

        remove3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        remove3.setText("<< Remove");
        remove3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                remove3ActionPerformed(evt);
            }
        });

        addsubj.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        addsubj.setText("Add Subject");
        addsubj.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addsubjActionPerformed(evt);
            }
        });

        save3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        save3.setText("Save");
        save3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                save3ActionPerformed(evt);
            }
        });

        cancel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        cancel3.setText("Cancel");
        cancel3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancel3ActionPerformed(evt);
            }
        });

        jPanel15.setBackground(new java.awt.Color(255, 255, 255));
        jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Chosen Subjects", 0, 0, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        sub2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Subject", "Description", "Units"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        sub2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                sub2MouseClicked(evt);
            }
        });
        jScrollPane9.setViewportView(sub2);

        jLabel28.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel28.setText("No. of Entries:");

        label4b.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        label4b.setText("000");

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel15Layout.createSequentialGroup()
                        .addGap(0, 348, Short.MAX_VALUE)
                        .addComponent(jLabel28)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label4b)))
                .addContainerGap())
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel28)
                    .addComponent(label4b)))
        );

        javax.swing.GroupLayout p3Layout = new javax.swing.GroupLayout(p3);
        p3.setLayout(p3Layout);
        p3Layout.setHorizontalGroup(
            p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(p3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p3Layout.createSequentialGroup()
                        .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(add3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(remove3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(10, 10, 10)
                        .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(p3Layout.createSequentialGroup()
                        .addComponent(addsubj, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 734, Short.MAX_VALUE)
                        .addComponent(save3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancel3)))
                .addContainerGap())
        );
        p3Layout.setVerticalGroup(
            p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(p3Layout.createSequentialGroup()
                .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(p3Layout.createSequentialGroup()
                                .addComponent(addsubj, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 21, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, p3Layout.createSequentialGroup()
                                .addGap(0, 22, Short.MAX_VALUE)
                                .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(cancel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(save3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(p3Layout.createSequentialGroup()
                        .addGap(144, 144, 144)
                        .addComponent(add3, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(remove3, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        mainP.addTab("Subject", p3);

        jSeparator2.setForeground(new java.awt.Color(0, 102, 51));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jSeparator1)
                            .addComponent(mainP, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(dateL)
                        .addGap(53, 53, 53)
                        .addComponent(timeL)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(usernameL)
                        .addGap(18, 18, 18)
                        .addComponent(logoutB)
                        .addGap(33, 33, 33))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dateL)
                    .addComponent(timeL)
                    .addComponent(usernameL)
                    .addComponent(logoutB))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(mainP, javax.swing.GroupLayout.PREFERRED_SIZE, 542, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mainPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainPMouseClicked
        if (mainP.getSelectedIndex() == 0) {
            try {
                int previous;
                int start = mi.getToday();
                previous = Integer.valueOf(start);

                int next;
                String end = mi.getRealYear();
                next = Integer.valueOf(end);

//                for (int x = previous; x < previous + 100; x++) {
//                    for (int y = x + 1; y < previous + 100; y++) {
//                        syCB.addItem(x + "-" + y);
//                        x = y;
//                    }
//                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (mainP.getSelectedIndex() == 1) {
            if (sss.equals("open")) {
                try {
                    if (currCB2.getItemCount() == 0) {
                        add2.setEnabled(false);
                        remove2.setEnabled(false);
                        save2.setEnabled(false);
                        cancel2.setEnabled(false);
                    } else {
                        add2.setEnabled(true);
                        remove2.setEnabled(true);
                        save2.setEnabled(true);
                        cancel2.setEnabled(true);
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
                currCB2.setEnabled(false);
                clevel1.setEnabled(false);
                add2.setEnabled(false);
                remove2.setEnabled(false);
                addclevel.setEnabled(false);
                save2.setEnabled(false);
            }
        } else if (mainP.getSelectedIndex() == 2) {
            if (sss.equals("open")) {
                try {
                    if (clevelCB3.getItemCount() == 0) {
                        add3.setEnabled(false);
                        remove3.setEnabled(false);
                        save3.setEnabled(false);
                        cancel3.setEnabled(false);
                    } else {
                        add3.setEnabled(true);
                        remove3.setEnabled(true);
                        save3.setEnabled(true);
                        cancel3.setEnabled(true);
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
//                clevelCB3.setEnabled(false);
                sub1.setEnabled(false);
                add3.setEnabled(false);
                remove3.setEnabled(false);
                addsubj.setEnabled(false);
                save3.setEnabled(false);
            }

        } else if (mainP.getSelectedIndex() == 3) {
            if (sss.equals("open")) {
                try {
//                    if (clevelCB4.getItemCount() == 0) {
//                        add4.setEnabled(false);
//                        remove4.setEnabled(false);
//                        save4.setEnabled(false);
//                        cancel4.setEnabled(false);
//                    } else {
//                        add4.setEnabled(true);
//                        remove4.setEnabled(true);
//                        save4.setEnabled(true);
//                        cancel4.setEnabled(true);
//                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
//                clevelCB4.setEnabled(false);
//                add4.setEnabled(false);
//                remove4.setEnabled(false);
//                addsubj.setEnabled(false);
//                save4.setEnabled(false);
            }

        }
    }//GEN-LAST:event_mainPMouseClicked

    private void save1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save1ActionPerformed
        try {
//            boolean add = false;
//            String startD = ((JTextField) startC.getDateEditor().getUiComponent()).getText();
//            String endD = ((JTextField) endC.getDateEditor().getUiComponent()).getText();
//            String sySelect = syCB.getSelectedItem().toString();
//
//            if (startD.isEmpty() || endD.isEmpty()) {
//                JOptionPane.showMessageDialog(null, "Please fill out the needed fields", "Error", JOptionPane.ERROR_MESSAGE);
//                label2a.setForeground(Color.red);
//                jLabel4.setForeground(Color.red);
//            } else if (startC.getDate().compareTo(endC.getDate()) > 0 || endC.getDate().compareTo(startC.getDate()) < 0) {
//                JOptionPane.showMessageDialog(null, "Invalid Date", "Error", JOptionPane.ERROR_MESSAGE);
//                label2a.setForeground(Color.red);
//                jLabel4.setForeground(Color.red);
//            } else if (numdays.getText().isEmpty()) {
//                JOptionPane.showMessageDialog(null, "Please click compute button", "Error", JOptionPane.ERROR_MESSAGE);
//                jLabel7.setForeground(Color.red);
//            } else {
//                boolean addA = false;
//                add = mi.add("add-sy", new SchoolYear(sySelect, startD, endD, Integer.valueOf(numdays.getText())), "", cUser);
//                SchoolYear syy = (SchoolYear) mi.get("get-sy", syCB.getSelectedItem().toString(), "");
//                syID = syy.getSyID() + "";
//                if (currTbl.getRowCount() == 2) {
//                    boolean a1 = mi.add("add-currsy", new SchoolYear(0, Integer.valueOf(selected.get(0).getCurrID()), Integer.valueOf(syy.getSyID())), "", cUser);
//                    boolean a2 = mi.add("add-currsy", new SchoolYear(0, Integer.valueOf(selected.get(1).getCurrID()), Integer.valueOf(syy.getSyID())), "", cUser);
//                    if (a1 && a2) {
//                        addA = true;
//                    }
//                } else {
//                    addA = mi.add("add-currsy", new SchoolYear(0, Integer.valueOf(selected.get(0).getCurrID()), Integer.valueOf(syy.getSyID())), "", cUser);
//                }
//                if (addA && add) {
//                    JOptionPane.showMessageDialog(null, "You have successfully opened a new school year.", "Success", JOptionPane.INFORMATION_MESSAGE);
//                    save1.setEnabled(false);
//                    remove1.setEnabled(false);
//                    syCB.setEnabled(false);
//                    p2.setEnabled(true);
//
//                    currCB2.removeAllItems();
//                    for (int x = 0; x < selected.size(); x++) {
//                        currCB2.addItem(selected.get(x).getCurrName());
//                    }
//
//                    mainP.setSelectedIndex(1);
//                    load1a();
//                    cleveldtm2 = new DefaultTableModel(new String[]{clevel2.getColumnName(0), clevel2.getColumnName(1), clevel2.getColumnName(2)}, 0);
//                    clevel2.setModel(cleveldtm2);
//                    mainPMouseClicked(null);
//                } else {
//                    JOptionPane.showMessageDialog(null, "A Server/Database error has occurred!", "Error", JOptionPane.ERROR_MESSAGE);
//                }
//            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_save1ActionPerformed

    private void logoutBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutBActionPerformed
        int x = JOptionPane.showConfirmDialog(null, "Are you sure you want to logout already?", "Alert!", JOptionPane.YES_NO_OPTION);
        if (x == JOptionPane.YES_OPTION) {
            try {
                mi.logout(cUser.getUsername());
                this.setVisible(false);
                new _Login().setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_logoutBActionPerformed

    private void mainPMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainPMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_mainPMouseEntered

    private void currCB2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_currCB2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_currCB2ActionPerformed

    private void add2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add2ActionPerformed
        //        // TODO add your handling code here:
        //        String sectionA = null;
        //        ArrayList<String> rev = new ArrayList<String>();
        //
        //        int[] sel = clevel1.getSelectedRows();
        ////        for(int i = 0; i < sel.length; i++) {
            //        for(int i = sel.length - 1; i >= 0; i--) {
                //            sectionA = (String) clevel1.getValueAt(sel[i], 0);
                ////            sectionA = (String) clTbl.getValueAt(clTbl.convertRowIndexToView(sel[i]), 0);
                //            rev.add(sectionA);
                //        }
            //
            //        for(int x = rev.size() - 1; x >= 0; x-- ) {
                ////            dtmc.addRow(new Object[] {rev.get(x).toString(), jComboBox1.getSelectedItem().toString()});
                ////            dtm2.removeRow(sel[x]);
                ////            dtm2.removeRow(clTbl.convertRowIndexToView(sel[x]));
                ////            dtm2.fireTableDataChanged();
                //        }

            //        if(clevel1.getRowCount() == 0) {
                //            JOptionPane.showMessageDialog (null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
                //        } else {
                //            int[] rows = clevel1.getSelectedRows();
                //            loadTbl2b(rows);
                //            remStud1(rows);
                //        }

            if (clevel1.getRowCount() == 0) {
                JOptionPane.showMessageDialog(null, "There is nothing to add!", "Error", JOptionPane.ERROR_MESSAGE);
            } else {
                int x = clevel1.getSelectedRowCount();
                if (x >= 1) {
                    int[] rows = clevel1.getSelectedRows();
                    add1b(rows);
                    rem1a(rows);
                } else {
                    JOptionPane.showMessageDialog(null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
                }
            }
    }//GEN-LAST:event_add2ActionPerformed

    private void remove2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove2ActionPerformed
        //        // TODO add your handling code here:
        //        String sectionA = null;
        //        String sectionB = null;
        //        ArrayList<String> rev = new ArrayList<String>();
        //
        //        int[] sel = clevel2.getSelectedRows();
        //        for(int i = sel.length - 1; i >= 0; i--) {
            //            sectionA = (String) clevel2.getValueAt(sel[i], 0);
            //            rev.add(sectionA);
            //            sectionB = clevel2.getValueAt(sel[i], 1).toString();
            //        }
        ////            if(!lst.contains(sectionA)) {
            //                for(int x = rev.size() - 1; x >= 0; x-- ) {
                ////                    dtm2.addRow(new Object[] {rev.get(x).toString()});
                //                    System.out.println(sel.length + " " + sel[x]);
                ////                    dtmc.removeRow(sel[x]);
                //                    //dtm.removeRow(chosenClTbl.getSelectedRows()[sel[x]]);
                ////                    dtmc.fireTableDataChanged();
                //                }
            ////            }

        if (clevel2.getRowCount() == 0) {
            JOptionPane.showMessageDialog(null, "There is nothing to remove!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            int x = clevel2.getSelectedRowCount();
            if (x >= 1) {
                int[] rows = clevel2.getSelectedRows();
                add1a(rows);
                rem1b(rows);
            } else {
                JOptionPane.showMessageDialog(null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_remove2ActionPerformed

    private void addclevelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addclevelActionPerformed
//        new ClassLevel_Manage(cUser, mi, this, "Add", null).setVisible(true);
    }//GEN-LAST:event_addclevelActionPerformed

    private void save2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save2ActionPerformed
        if(save2.getText().equals("Edit")) {
            currCB2.setEnabled(true);
            clevel1.setEnabled(true);
            add2.setEnabled(true);
            remove2.setEnabled(true);
            addclevel.setEnabled(true);
            save2.setText("Update");
//            loadCurrCB2();
            load1a();
        } else {
            try {
                //                if(save2.getText().equals("Update")) {//edit
//                    ArrayList<ClassLevel> clevels = (ArrayList<ClassLevel>) mi.getList2("getlist2-clevelcurrView", syCB.getSelectedItem().toString(), "").clone();
//                    if(clevels != null) {
//                        System.out.println("sss  " + sy.getSyID());
//                        boolean r = mi.edit("edit-clevelsy", sy.getSyID(), cUser);
//                    }
                    //                    if(r) {
                        //                        System.out.println("aaaaaa");
                        //                    }
                    //                } else {//add
                    boolean success = false;

                    for (int x = 0; x < cl2.size(); x++) {
                        try {
                            ClassLevel cl = cl2.get(x);
                            System.out.println("ss00 " + cl.getCurrID());
                            System.out.println("ss01 " + sy.getSyID());
                            String currsy = (String) mi.get("get-currsyID", cl.getCurrID(), sy.getSyID() + "");
                            System.out.println("ss1 " + currsy);
                            String cclid = (String) mi.get("get-currclID", cl.getClassID(), currsy);
                            System.out.println("ss2 " + cclid);
                            System.out.println("ss3 " + cl.getClassID());
                            if (cclid == null) {
                                System.out.println("re");
                                success = mi.add("add-currcl", new ClassLevel(Integer.valueOf(cl.getClassID()), Integer.valueOf(currsy)), "", cUser);
                            } else {
                                success = true;
                            }

                        } catch (Exception ex) {
                            ex.printStackTrace();
                        }
                    }

                    if (success) {
                        try {
                            if(save2.getText().equals("Update")) {
//                                JOptionPane.showMessageDialog(null, "Class level/s successfully updated to the school year : " + syCB.getSelectedItem().toString(), "Success", JOptionPane.INFORMATION_MESSAGE);
                            } else {
//                                JOptionPane.showMessageDialog(null, "Class level/s successfully added to the school year : " + syCB.getSelectedItem().toString(), "Success", JOptionPane.INFORMATION_MESSAGE);
                            }
                            clevelsyList = (ArrayList<ClassLevel>) mi.getList2("getlist2-clevelsy", sy.getSyID() + "", "").clone();
                            clevelCB3.removeAllItems();
//                            clevelCB4.removeAllItems();
                            for (int x = 0; x < clevelsyList.size(); x++) {
                                System.out.println(clevelsyList.get(x).getClassName());
                                clevelCB3.addItem(clevelsyList.get(x).getClassName());
//                                clevelCB4.addItem(clevelsyList.get(x).getClassName());
                            }
                            load2a();
                            subjdtm2 = new DefaultTableModel(new String[]{sub2.getColumnName(0), sub2.getColumnName(1), sub2.getColumnName(2)}, 0);
                            sub2.setModel(subjdtm2);
                            load3a();
//                            secdtm2 = new DefaultTableModel(new String[]{secT2.getColumnName(0), secT2.getColumnName(1)}, 0);
//                            secT2.setModel(secdtm2);
                            mainP.setSelectedIndex(2);
                            mainPMouseClicked(null);
                            mainP.setEnabledAt(2, true);
                            mainP.setEnabledAt(3, true);
                        } catch (Exception ex) {
                            ex.printStackTrace();
                        }
                    } else {
                        JOptionPane.showMessageDialog(null, "A Server/Database error has occurred!", "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    //                }
            } catch (Exception ex) {
                Logger.getLogger(CurrDetails.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_save2ActionPerformed

    private void cancel2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cancel2ActionPerformed

    private void clevel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clevel2MouseClicked
        // TODO add your handling code here:
        //        if(evt.getClickCount() == 2) {
            //                int x1 = clevel2.getSelectedColumn();
            //                while(x1 != 0) {
                //                    x1--;
                //                }
            //
            //                int x2 = clevel2.getSelectedColumn();
            //                while(x2 != 1) {
                //                    x2++;
                //                }
            //
            //                int y = clevel2.getSelectedRow();
            //                mcClevelTbl1.getCellRenderer(y, x);
            //                cll = (String) chosenClTbl.getValueAt(y, x1);
            //                JOptionPane.showMessageDialog(null, cll);
            //                cur = chosenClTbl.getValueAt(y, x2).toString();
            //                if(lst.contains(cll)) {
                //                    int p = JOptionPane.showConfirmDialog(null,"Are you sure you want to Change/Edit the Subject/s of this Class Level?","Alert!",JOptionPane.YES_NO_OPTION);
                //                        if(p == JOptionPane.YES_OPTION){
                    ////                            this.setVisible(false);
                    ////                            new CurriculumCSE_Manage(cUser, ccu, val, mi, lst, ck).setVisible(true);
                    ////                              cll = chosenClTbl.getValueAt(chosenClTbl.getSelectedRow(), 0).toString();
                    //                              jTabbedPane1.setSelectedIndex(2);
                    //                              jLabel18.setText(cur);
                    //                              jLabel17.setText(cll);
                    //                              jLabel19.setText(jLabel15.getText());
                    //                              jTabbedPane1.repaint();
                    //                        }
                //                }else {
                ////                    this.setVisible(false);
                ////                    new CurriculumCSE_Manage(cUser, ccu, val, mi, lst, ck).setVisible(true);
                ////                    cll = chosenClTbl.getValueAt(chosenClTbl.getSelectedRow(), 0).toString();a
                //                    jTabbedPane1.setSelectedIndex(2);
                //                    jLabel18.setText(cur);
                //                    jLabel17.setText(cll);
                //                    jLabel19.setText(jLabel15.getText());
                //                    jTabbedPane1.repaint();
                //                }
            //            }
    }//GEN-LAST:event_clevel2MouseClicked

    private void clevelCB3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clevelCB3ActionPerformed
        //        if(sss.equals("view")) {
            //            load2b();
            //        } else {
            load2a();
            label4a.setText(subj1.size() + "");
            load2b();
            //        }
    }//GEN-LAST:event_clevelCB3ActionPerformed

    private void add3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add3ActionPerformed
        if (sub1.getRowCount() == 0) {
            JOptionPane.showMessageDialog(null, "There is nothing to add!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            int x = sub1.getSelectedRowCount();
            if (x >= 1) {
                int[] rows = sub1.getSelectedRows();
                add2b(rows);
                rem2a(rows);
            } else {
                JOptionPane.showMessageDialog(null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_add3ActionPerformed

    private void remove3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove3ActionPerformed
        if (sub2.getRowCount() == 0) {
            JOptionPane.showMessageDialog(null, "There is nothing to remove!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            int x = sub2.getSelectedRowCount();
            if (x >= 1) {
                int[] rows = sub2.getSelectedRows();
                add2a(rows);
                rem2b(rows);
            } else {
                JOptionPane.showMessageDialog(null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_remove3ActionPerformed

    private void addsubjActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addsubjActionPerformed
//        new Subject_Manage(cUser, mi, clevelsyList, this, "Add", null).setVisible(true);
    }//GEN-LAST:event_addsubjActionPerformed

    private void save3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save3ActionPerformed
        if(save3.getText().equals("Edit")) {
            clevelCB3.setEnabled(true);
            sub1.setEnabled(true);
            add3.setEnabled(true);
            remove3.setEnabled(true);
            addsubj.setEnabled(true);
            save3.setEnabled(true);
            save3.setText("Update");
            load2a();
        } else {
            try {
                boolean success = false;
                //            ArrayList<Subject> existing = null;
                //            try {
                    //                existing = (ArrayList<Subject>) mi.getList2("getlist2-subjforclevel", clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID(), "").clone();
                    //            } catch (Exception ex) {
                    //                ex.printStackTrace();
                    //            }
                ArrayList<Subject> subjects = (ArrayList<Subject>) mi.getList2("getlist2-subjforclevel", clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID(), "").clone();
                if(subjects != null) {
                    System.out.println("sss  " + sy.getSyID());
                    boolean r = mi.edit("edit-clevelsub", clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID(), cUser);
                    if(r) {
                        System.out.println("iii");
                    }
                }
                System.out.println(subj2.size());
                for (int x = 0; x < subj2.size(); x++) {

                    //                    if (existing.size() != 0) {
                        //                        for (int y = 0; y < existing.size(); y++) {
                            //                            Subject s = subj2.get(x);
                            //                            if (!existing.get(y).getsubID().equals(s.getsubID())) {
                                //                                s.setCurrclID(clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID());
                                //                                System.out.println(s.getsubID() + " " + s.getCurrclID());
                                //                                success = mi.add("add-currcls", s, "", cUser);
                                //                            }
                            //                        }
                        //                    } else {

                        Subject s = subj2.get(x);
                        s.setCurrclID(clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID());
                        System.out.println(s.getsubID() + " " + s.getCurrclID());

                        success = mi.add("add-currcls", s, "", cUser);
                        //                    }

                }

                if (success) {
                    try {
                        if(save3.getText().equals("Update")) {
//                            JOptionPane.showMessageDialog(null, "Subject/s successfully updated to " + clevelCB3.getSelectedItem() + "\nat school year : " + syCB.getSelectedItem().toString(), "Success", JOptionPane.INFORMATION_MESSAGE);
                        } else {
//                            JOptionPane.showMessageDialog(null, "Subject/s successfully added to " + clevelCB3.getSelectedItem() + "\nat school year : " + syCB.getSelectedItem().toString(), "Success", JOptionPane.INFORMATION_MESSAGE);
                        }
                        /*
                        * clevelsyList = (ArrayList<ClassLevel>)
                        * mi.getList2("getlist2-clevelsy", syID).clone();
                        * clevelCB3.removeAllItems(); for(int x = 0; x <
                            * clevelsyList.size(); x++) {
                            * System.out.println(clevelsyList.get(x).getClassName());
                            * clevelCB3.addItem(clevelsyList.get(x).getClassName()); }
                        * load2a(); mainP.setSelectedIndex(2);
                        mainPMouseClicked(null);
                        */
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "A Server/Database error has occurred!", "Error", JOptionPane.ERROR_MESSAGE);
                }
            } catch (Exception ex) {
                Logger.getLogger(CurrDetails.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_save3ActionPerformed

    private void cancel3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cancel3ActionPerformed

    private void sub2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sub2MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_sub2MouseClicked

    public void loadTable() {
        if (mainP.getSelectedIndex() == 1) {
//            try {
//                for(int x = 0; x < chCurr.size(); x++) {
//                    jComboBox1.addItem(chCurr.get(x));
//                }
//    //            
//    //            classList = mi.getList("classlevels2");
//    //            cl = new ArrayList<ClassLevel>();
//    //            for(int x = 0; x < classList.size(); x++) {
//    //                cl.add((ClassLevel) classList.get(x));
//    //            }
//    //                         
//    //            dtm = new DefaultTableModel(new String[] {chosenClTbl.getColumnName(0)}, 0);
//    //            chosenClTbl.setModel(dtm);
//    //            for(int x = 0; x < cl.size(); x++) {
//    //                dtm.insertRow(x, new Object[] {cl.get(x).getClasslevel()});
//    //            }
//    //            
//    //            for(int c = 0; c < dtm.getRowCount(); c++) {
//    //                chkList.add(chosenClTbl.getValueAt(c, 0).toString());
//    //            }
//
//                dtm2 = new DefaultTableModel(new String[] {clTbl.getColumnName(0)}, 0);
//                clTbl.setModel(dtm2);
//
//                lvlList = mi.getList("classlevels");
//                ArrayList<ClassLevel> ls = new ArrayList<ClassLevel>();
//                for(int x = 0; x < lvlList.size(); x++) {
//                    ls.add((ClassLevel) lvlList.get(x));
//                }
//
//                String chk = null;
//                for(int x = 0; x < ls.size(); x++) {
//                    chk = ls.get(x).getClasslevel();
//                    if(!chkList.contains(chk)) {
//                        dtm2.addRow(new Object[] {ls.get(x).getClasslevel()});                
//                    }
//                } 
//            } catch(Exception e) {
//                e.printStackTrace();
//            }
        }
    }

    public void loadCurrSY(String a) {
        try {
            if (a.equals("add")) {
                ArrayList<String> listsy = (ArrayList<String>) mi.getList("getlist-sylist").clone();
                int previous = Integer.valueOf(mi.getToday());
                for (int x = previous; x < previous + 100; x++) {
                    for (int y = x + 1; y < previous + 100; y++) {
                        if (!listsy.contains(x + "-" + y)) {
//                            syCB.addItem(x + "-" + y);
                        }
                        x = y;
                    }
                }
            } else {
                ArrayList<String> listsy = (ArrayList<String>) mi.getList("getlist-sylist").clone();
                for (int x = 0; x < listsy.size(); x++) {
//                    syCB.addItem(listsy.get(x));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void loadCurrCB() {
//        currCB.removeAllItems();
//        try {
//            for (int x = 0; x < currList.size(); x++) {
//                currCB.addItem(currList.get(x).getCurrName());
//            }
//        } catch (Exception ex) {
//            ex.printStackTrace();
//        }
    }

    public void load1a() {
        try {
            clevelList = (ArrayList<ClassLevel>) mi.getList("getlist-classlevels").clone();
            cl1 = (ArrayList<ClassLevel>) clevelList.clone();
            cleveldtm1 = new DefaultTableModel(new String[]{clevel1.getColumnName(0), clevel1.getColumnName(1)}, 0);
            clevel1.setModel(cleveldtm1);

            ArrayList<ClassLevel> t = new ArrayList<ClassLevel>();
            for (int x = 0; x < cl1.size(); x++) {
                if (cl2.size() != 0) {
                    boolean e = false;
                    for (int y = 0; y < cl2.size(); y++) {
                        if (cl1.get(x).getClassName().equals(cl2.get(y).getClassName())) {
                            e = true;
                        }
                    }

                    if (!e) {
                        t.add(cl1.get(x));
                        cleveldtm1.addRow(new Object[]{cl1.get(x).getClassName(), cl1.get(x).getClassCategory()});
                    }
                } else {
                    cleveldtm1.addRow(new Object[]{cl1.get(x).getClassName(), cl1.get(x).getClassCategory()});
                }
            }

            if (cl2.size() != 0) {
                cl1 = (ArrayList<ClassLevel>) t.clone();
            }
            label2a.setText(cl1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void load1b() {
        try {
//            System.out.println("kkkppp " + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassID() + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassName());
//            ArrayList<ClassLevel> clevels = (ArrayList<ClassLevel>) mi.getList2("getlist2-clevelcurrView", syCB.getSelectedItem().toString(), "").clone();
//            cleveldtm2 = new DefaultTableModel(new String[]{clevel2.getColumnName(0), clevel2.getColumnName(1), clevel2.getColumnName(2)}, 0);
//            clevel2.setModel(cleveldtm2);
//            for (int y = 0; y < clevels.size(); y++) {
//                ClassLevel c = clevels.get(y);
//                cleveldtm2.addRow(new Object[]{c.getClassName(), c.getClassCategory(), c.getCurriculum()});
//
//                label2b.setText(cl2.size() + "");
//            }
//            clevelsyList = (ArrayList<ClassLevel>) clevels.clone();
//            for (int x = 0; x < clevelsyList.size(); x++) {
//                clevelCB3.addItem(clevelsyList.get(x).getClassName());
////                clevelCB4.addItem(clevelsyList.get(x).getClassName());
//            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void add1a(int[] arr) {
        for (int x = 0; x < arr.length; x++) {
            ClassLevel s = cl2.get(arr[x]);
            cl1.add(s);
            cleveldtm1.addRow(new Object[]{s.getClassName(), s.getClassCategory()});
        }
        label2a.setText(cl1.size() + "");
    }

    public void add1b(int[] arr) {
        for (int x = 0; x < arr.length; x++) {
            ClassLevel c = cl1.get(arr[x]);
            for (int y = 0; y < clevelList.size(); y++) {
                if (clevelList.get(y).getClassName().equals(c.getClassName())) {
                    c.setClassID(clevelList.get(y).getClassID());
                }
            }

            c.setCurriculum(currCB2.getSelectedItem() + "");
            c.setCurrID(selected.get(currCB2.getSelectedIndex()).getCurrID());
            cl2.add(c);
            cleveldtm2.addRow(new Object[]{c.getClassName(), c.getClassCategory(), c.getCurriculum()});
        }
        label2b.setText(cl2.size() + "");
    }

    public void rem1a(int[] ii) {
        ArrayList<ClassLevel> clevel = (ArrayList<ClassLevel>) cl1.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            clevel.remove(ii[x]);
        }

        cl1 = (ArrayList<ClassLevel>) clevel.clone();
        try {
            cleveldtm1 = new DefaultTableModel(new String[]{clevel1.getColumnName(0), clevel1.getColumnName(1)}, 0);
            clevel1.setModel(cleveldtm1);
            for (int x = 0; x < cl1.size(); x++) {
                ClassLevel s = cl1.get(x);
                cleveldtm1.addRow(new Object[]{s.getClassName(), s.getClassCategory()});
            }
            label2a.setText(cl1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void rem1b(int[] ii) {
        ArrayList<ClassLevel> clevel = (ArrayList<ClassLevel>) cl2.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            clevel.remove(ii[x]);
        }

        cl2 = (ArrayList<ClassLevel>) clevel.clone();
        try {
            cleveldtm2 = new DefaultTableModel(new String[]{clevel2.getColumnName(0), clevel2.getColumnName(1), clevel2.getColumnName(2)}, 0);
            clevel2.setModel(cleveldtm2);
            for (int x = 0; x < cl2.size(); x++) {
                ClassLevel s = cl2.get(x);
                cleveldtm2.addRow(new Object[]{s.getClassName(), s.getClassCategory(), s.getCurriculum()});
            }
            label2b.setText(cl2.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void load2a() {
        try {
//            System.out.println("kkk " + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassID() + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassName());
            subjList = (ArrayList<Subject>) mi.getList2("getlist2-clsubjList", clevelsyList.get(clevelCB3.getSelectedIndex()).getClassID(), clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID()).clone();
            subj1 = (ArrayList<Subject>) subjList.clone();
            subjdtm1 = new DefaultTableModel(new String[]{sub1.getColumnName(0), sub1.getColumnName(1), sub2.getColumnName(2)}, 0);
            sub1.setModel(subjdtm1);

            ArrayList<Subject> t = new ArrayList<Subject>();
            for (int x = 0; x < subj1.size(); x++) {
                Subject s = subj1.get(x);
                if (s.getUnits().equals("0")) {
                    s.setUnits("None");
                }
                if (subj2.size() != 0) {
                    boolean e = false;
                    for (int y = 0; y < subj2.size(); y++) {
                        if (subj1.get(x).getSubjName().equals(subj2.get(y).getSubjName())) {
                            e = true;
                        }
                    }

                    if (!e) {
                        t.add(s);
                        subjdtm1.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
                    }
                } else {
                    subjdtm1.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
                }
            }
            if (subj2.size() != 0) {
                subj1 = (ArrayList<Subject>) t.clone();
            }
            label4a.setText(subj1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void load2b() {
        try {
//            System.out.println("kkkppp " + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassID() + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassName());
//            if(sss.equals("view")) {
//                subj2 = (ArrayList<Subject>) mi.getList2("getlist2-clsubjList", clevelsyList.get(clevelCB3.getSelectedIndex()).getClassID(), clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID()).clone();
//            } else {
                subj2 = (ArrayList<Subject>) mi.getList2("getlist2-subjforclevel", clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID(), "").clone();
            
//            }
            subjdtm2 = new DefaultTableModel(new String[]{sub2.getColumnName(0), sub2.getColumnName(1), sub2.getColumnName(2)}, 0);
            sub2.setModel(subjdtm2);
            if (subj2.size() != 0) {
                for (int x = 0; x < subj2.size(); x++) {
                    Subject s = subj2.get(x);
                    if (s.getUnits().equals("0")) {
                        s.setUnits("None");
                    }
                    subjdtm2.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
                }
            }
            label4b.setText(subj2.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void add2a(int[] arr) {
        System.out.println("arr " + arr.length);
        for (int x = 0; x < arr.length; x++) {
            Subject s = subj2.get(arr[x]);
            subj1.add(s);
            subjdtm1.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
        }
        label4a.setText(subj1.size() + "");
    }

    public void add2b(int[] arr) {
        for (int x = 0; x < arr.length; x++) {
            Subject s = subj1.get(arr[x]);
            subj2.add(s);
            subjdtm2.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
        }
        label4b.setText(subj2.size() + "");
    }

    public void rem2a(int[] ii) {
        ArrayList<Subject> subj = (ArrayList<Subject>) subj1.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            subj.remove(ii[x]);
        }

        subj1 = (ArrayList<Subject>) subj.clone();
        try {
            subjdtm1 = new DefaultTableModel(new String[]{sub1.getColumnName(0), sub1.getColumnName(1), sub1.getColumnName(2)}, 0);
            sub1.setModel(subjdtm1);
            for (int x = 0; x < subj1.size(); x++) {
                Subject s = subj1.get(x);
                subjdtm1.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
            }
            label4a.setText(subj1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void rem2b(int[] ii) {
        ArrayList<Subject> subj = (ArrayList<Subject>) subj2.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            subj.remove(ii[x]);
        }

        subj2 = (ArrayList<Subject>) subj.clone();
        try {
            subjdtm2 = new DefaultTableModel(new String[]{sub2.getColumnName(0), sub2.getColumnName(1), sub2.getColumnName(2)}, 0);
            sub2.setModel(subjdtm2);
            for (int x = 0; x < subj2.size(); x++) {
                Subject s = subj2.get(x);
                subjdtm2.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
            }
            label4b.setText(subj2.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void load3a() {
        try {
//            System.out.println("kkk " + clevelsyList.get(clevelCB4.getSelectedIndex()).getClassID() + clevelsyList.get(clevelCB4.getSelectedIndex()).getClassName());
//            secList = (ArrayList<Sections>) mi.getList2("getlist2-clsecList", clevelsyList.get(clevelCB4.getSelectedIndex()).getClassID(), clevelsyList.get(clevelCB4.getSelectedIndex()).getCurrclID()).clone();
//            sec1 = (ArrayList<Sections>) secList.clone();
//            secdtm1 = new DefaultTableModel(new String[]{secT1.getColumnName(0)}, 0);
//            secT1.setModel(secdtm1);
//
//            ArrayList<Sections> t = new ArrayList<Sections>();
//            for (int x = 0; x < sec1.size(); x++) {
//                Sections s = sec1.get(x);
//                if (sec2.size() != 0) {
//                    boolean e = false;
//                    for (int y = 0; y < sec2.size(); y++) {
//                        if (sec2.get(x).getSect().equals(sec2.get(y).getSect())) {
//                            e = true;
//                        }
//                    }
//
//                    if (!e) {
//                        t.add(s);
//                        secdtm1.addRow(new Object[]{s.getSect()});
//                    }
//                } else {
//                    secdtm1.addRow(new Object[]{s.getSect()});
//                }
//            }
//            if (sec2.size() != 0) {
//                sec1 = (ArrayList<Sections>) t.clone();
//            }
//            label5a.setText(sec1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void load3b() {
        try {
//            System.out.println("kkkppp " + clevelsyList.get(clevelCB4.getSelectedIndex()).getClassID() + clevelsyList.get(clevelCB4.getSelectedIndex()).getClassName());
//            if(!sss.equals("view")) {
//                sec2 = (ArrayList<Sections>) mi.getList2("getlist2-secforclevel", clevelsyList.get(clevelCB4.getSelectedIndex()).getCurrclID(), "").clone();
////            } else {
////                sec2 = (ArrayList<Sections>) mi.getList2("getlist2-clsecList", clevelsyList.get(clevelCB4.getSelectedIndex()).getClassID(), clevelsyList.get(clevelCB4.getSelectedIndex()).getCurrclID()).clone();
////            }
//            secdtm2 = new DefaultTableModel(new String[]{secT2.getColumnName(0), secT2.getColumnName(1)}, 0);
//            secT2.setModel(secdtm2);
//            if (sec2.size() != 0) {
//                for (int x = 0; x < sec2.size(); x++) {
//                    Sections s = sec2.get(x);
//                    if(s.getAdv() == null) {
//                        secdtm2.addRow(new Object[]{s.getSect(), "None"});
//                    } else {
//                        secdtm2.addRow(new Object[]{s.getSect(), s.getAdv().getName()});
//                    }
//                    
//                }
//            }
//            label5b.setText(sec2.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void add3a(int[] arr) {
        System.out.println("arr " + arr.length);
        for (int x = 0; x < arr.length; x++) {
            Sections s = sec2.get(arr[x]);
            sec1.add(s);
            secdtm1.addRow(new Object[]{s.getSect()});
        }
//        label5a.setText(sec2.size() + "");
    }

    public void add3b(int[] arr) {
        for (int x = 0; x < arr.length; x++) {
            try {
                Sections s = sec1.get(arr[x]);
                User secadv = (User) mi.get("get-secadv", s.getSecID() + "", s.getCurrclID() + "");
                if (secadv == null) {
                    s.setAdv(null);
                    secdtm2.addRow(new Object[]{s.getSect(), "None"});
                } else {
                    s.setAdv(secadv);
                    secdtm2.addRow(new Object[]{s.getSect(), s.getAdv().getName()});
                }
                sec2.add(s);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
//        label5b.setText(sec2.size() + "");
    }

    public void rem3a(int[] ii) {
        ArrayList<Sections> se = (ArrayList<Sections>) sec1.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            se.remove(ii[x]);
        }

        sec1 = (ArrayList<Sections>) se.clone();
        try {
//            secdtm1 = new DefaultTableModel(new String[]{secT1.getColumnName(0)}, 0);
//            secT1.setModel(secdtm1);
            for (int x = 0; x < sec1.size(); x++) {
                Sections s = sec1.get(x);
                secdtm1.addRow(new Object[]{s.getSect()});
            }
//            label5a.setText(sec1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void rem3b(int[] ii) {
        ArrayList<Sections> se = (ArrayList<Sections>) sec2.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            se.remove(ii[x]);
        }

        sec2 = (ArrayList<Sections>) se.clone();
        try {
//            secdtm2 = new DefaultTableModel(new String[]{secT2.getColumnName(0)}, 0);
//            secT2.setModel(secdtm2);
//            for (int x = 0; x < sec2.size(); x++) {
//                Sections s = sec2.get(x);
//                if(s.getAdv() == null) {
//                    secdtm2.addRow(new Object[]{s.getSect(), "None"});
//                } else {
//                    secdtm2.addRow(new Object[]{s.getSect(), s.getAdv().getName()});
//                }
//            }
//            label5b.setText(sec2.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void setAdviser(int index, User u) {
        Sections s = sec2.get(index);
        s.setAdv(u);
        if(s.getAdv() == null) {
            secdtm2.setValueAt("None", index, 1);
        } else {
            secdtm2.setValueAt(u.getName(), index, 1);
        }
    }
    
    public ArrayList<String> getAdvisers() {
        ArrayList<String> a = new ArrayList<String>();
//        for(int x = 0; x < secT2.getRowCount(); x++) {
//            String s = secdtm2.getValueAt(x, 1).toString();
//            if(!s.equals("None")) {
//                a.add(s);
//                System.out.println("get " + s);
//            }
//        }
        return a;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(_UAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(_UAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(_UAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(_UAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new CurrDetails1(cUser, mi, sss, curr).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton add2;
    private javax.swing.JButton add3;
    private javax.swing.JButton addclevel;
    private javax.swing.JButton addsubj;
    private javax.swing.JButton cancel1;
    private javax.swing.JButton cancel2;
    private javax.swing.JButton cancel3;
    private javax.swing.JTable clevel1;
    private javax.swing.JTable clevel2;
    private javax.swing.JComboBox clevelCB3;
    private javax.swing.JComboBox currCB2;
    private javax.swing.JLabel dateL;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JLabel label2a;
    private javax.swing.JLabel label2b;
    private javax.swing.JLabel label4a;
    private javax.swing.JLabel label4b;
    private javax.swing.JButton logoutB;
    private javax.swing.JTabbedPane mainP;
    private javax.swing.JPanel p1;
    private javax.swing.JPanel p2;
    private javax.swing.JPanel p3;
    private javax.swing.JButton remove2;
    private javax.swing.JButton remove3;
    private javax.swing.JButton save1;
    private javax.swing.JButton save2;
    private javax.swing.JButton save3;
    private javax.swing.JTable sub1;
    private javax.swing.JTable sub2;
    private javax.swing.JLabel timeL;
    private javax.swing.JLabel usernameL;
    // End of variables declaration//GEN-END:variables
}
